package GameMain.View.PTGame
{
	import GameMain.Game;
	import GameMain.View.PTGame.GameManager;
	
	import Interface.UIControl.ITextBase;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	import library.Function.GlobalFun;
	
	public class PlayerHP extends Sprite
	{
		private var _content:MovieClip = null;
		private var _playerNameTxt:ITextBase = null;
		
		
		public function PlayerHP()
		{
			super();
			this._content = new GameManager.playerHpBarClass() as MovieClip;
			this._content.gotoAndStop(100);
			this.addChild(this._content);
			this._content.x = -60/2; //居中
			this.graphics.lineStyle();
			this.graphics.beginFill(0x111111,0.6);
			this.graphics.drawRect(-60/2, 0, 60,12);
			this.graphics.endFill();
			
			this._playerNameTxt = Game.ControlMgr.getText();
			GlobalFun.setTextFormat(this._playerNameTxt.textField,"SimSun",12,true,0xffffff);
			this._playerNameTxt.textField.multiline = false;
			this._playerNameTxt.textField.wordWrap = false;
			this.addChild(this._playerNameTxt.textField);
			this._playerNameTxt.textField.y = 15;
		}
		
		public function setPlayerHp(hp:int):void
		{
			this._content.gotoAndStop(hp);
		}
		
		public function setPlayerName(txt:String):void
		{
			this._playerNameTxt.text = txt;
			this._playerNameTxt.textField.x = -this._playerNameTxt.textField.textWidth/2
		}
	}
}